public class AutoPlay{
     int x,y;
     void autoPlay(int chesspad[][],int a,int b){
          int randomNumber=(int)(Math.random()*8)+1;
          switch(randomNumber){
             case(1):
                  if(chesspad[a-1][b-1]==0)
                  {x=a-1;y=b-1;}
                  else if(chesspad[a-2][b-2]==0)
                  {x=a-2;y=b-2;}
                  else {x=a-3;y=b-3;}   
                  break;
                   
             case(2):
                  if(chesspad[a-1][b]==0)
                  {x=a-1;y=b;}
                  else if(chesspad[a-2][b]==0)
                  {x=a-2;y=b;}
                  else {x=a-3;y=b;}
                  break;
	     case(3):
                  if(chesspad[a-1][b+1]==0)
                  {x=a-1;y=b+1;}
                  else if(chesspad[a-2][b+2]==0)
                  {x=a-2;y=b+2;}
                  else {x=a-3;y=b+3;}
                  break;
             case(4):
                  if(chesspad[a][b+1]==0)
                  {x=a;y=b+1;}
                  else if(chesspad[a][b+2]==0)
                  {x=a;y=b+2;}
                  else {x=a;y=b+3;}
                  break;
             case(5):
                   if(chesspad[a+1][b+1]==0)
                   {x=a+1;y=b+1;}
                   else if(chesspad[a+2][b+2]==0)
                   {x=a+2;y=b+2;} 
                   else {x=a+3;y=b+3;}
                   break;
             case(6):
                   if(chesspad[a+1][b]==0)
                   {x=a+1;y=b;}
                   else  if(chesspad[a+2][b]==0)
                   {x=a+2;y=b;}
                   else {x=a+3;y=b;}
                   break;
             case(7):
                    if(chesspad[a+1][b-1]==0)
                    {x=a+1;y=b-1;}
                    else if(chesspad[a+2][b-2]==0)
                    {x=a+2;y=b-2;}
                    else {x=a+3;y=b-3;}
                    break;
             case(8):
                     if(chesspad[a][b-1]==0)
                     {x=a;y=b-1;}
                     else if(chesspad[a][b-2]==0)
                     {x=a;y=b-2;}
                     else{x=a;y=b+3;}
                     break; 
            }
      }
} 